package ewa

import (
    "time"
)

/*
----- For SQLite3 -----
CREATE TABLE IF NOT EXISTS "%s"(
   "UserId" INTEGER PRIMARY KEY AUTOINCREMENT,
   "Username" VARCHAR(100) NOT NULL UNIQUE,
   "Password" VARCHAR(40) NOT NULL,
   "Email" VARCHAR(100) NOT NULL,
   "Hiredate" DATE, 
   "Regtime" DATETIME
);

----- For MySQL -----
CREATE TABLE IF NOT EXISTS %s(
   UserId INT UNSIGNED AUTO_INCREMENT,
   Username VARCHAR(100) NOT NULL,
   Password VARCHAR(40) NOT NULL,
   Email VARCHAR(100) NOT NULL,
   Hiredate DATE, 
   Regtime DATETIME,
   PRIMARY KEY (UserId),
   UNIQUE KEY Username (Username)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

 */

type UserAuthTabDesc struct{
    UserId       int
    Username     string
    Password     string
    Email        string
    Hiredate     string   //9999-12-32
    Regtime      string   //9999-12-31 23:59:59
}

const (
    DefaultAdminUsername = "Admin" 
)

func DefaultAdmin() UserAuthTabDesc {
  return UserAuthTabDesc{
        Username: DefaultAdminUsername,
        Password: "Admin",
        Email:  "Administrator@qq.com",
        Regtime: time.Now().Format("2006-01-02 15:04:05"),
        Hiredate: "1970-01-01",
    } 
}

func DefaultUser(user string, pass string) UserAuthTabDesc {
  return UserAuthTabDesc{
        Username: user,
        Password: pass,
        Email:  user+"@qq.com",
        Regtime: time.Now().Format("2006-01-02 15:04:05"),
        Hiredate: "1970-01-01",
    } 
}